package edu.ynu.se.xiecheng.achitectureclass.GreenHouse.GreenhouseService;


import edu.ynu.se.xiecheng.achitectureclass.GreenHouse.GreenhouseDao.TokenDAO;
import edu.ynu.se.xiecheng.achitectureclass.GreenHouse.GreenhouseEntity.Token;
import edu.ynu.se.xiecheng.achitectureclass.common.service.LogicService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TokenService extends LogicService<TokenDAO, Token, Long> {
    public TokenService(TokenDAO dao) {
        super(dao);
    }

    // 根据 tokenValue 查找最新的 Token
    public Token findByTokenValue(String tokenValue) {
        List<Token> tokens = getDAO().findByTokenValue(tokenValue);
        return tokens.isEmpty() ? null : tokens.get(0);
    }

    // 根据 tokenType 查找最新的 Token
    public Token findByTokenType(String tokenType) {
        List<Token> tokens = getDAO().findByTokenType(tokenType);
        return tokens.isEmpty() ? null : tokens.get(0);
    }
}